package flc.ast.adapter;

import android.view.View;
import android.widget.ImageView;

import androidx.annotation.NonNull;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.provider.BaseItemProvider;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;

import flc.ast.R;
import flc.ast.bean.MyAlbumBean;
import flc.ast.bean.MyAlbumItemBean;
import stark.common.basic.adaptermutil.StkProviderMultiAdapter;
import stark.common.basic.adaptermutil.StkSingleSpanProvider;

public class AlbumDetailAdapter extends StkProviderMultiAdapter<MyAlbumItemBean> {

    public AlbumDetailAdapter() {
        addItemProvider(new StkSingleSpanProvider<>(80));
        addItemProvider(new AlbumDetailProvider());
    }

    private boolean isPrivacy = false;

    public void setPrivacy(boolean privacy) {
        isPrivacy = privacy;
    }

    private class AlbumDetailProvider extends BaseItemProvider<MyAlbumItemBean> {
        @Override
        public int getItemViewType() {
            return StkProviderMultiAdapter.TYPE_VIEW;
        }

        @Override
        public int getLayoutId() {
            return R.layout.item_album_detail;
        }

        @Override
        public void convert(@NonNull BaseViewHolder baseViewHolder, MyAlbumItemBean bean) {
            if (bean.isSelect()) {
                Glide.with(getContext()).load(bean.getPath())
                        .into((ImageView) baseViewHolder.getView(R.id.ivAlbumDetailItemSelImg));
                baseViewHolder.getView(R.id.ivAlbumDetailItemSelImg).setVisibility(View.VISIBLE);
                baseViewHolder.getView(R.id.ivAlbumDetailItemImg).setVisibility(View.GONE);
                baseViewHolder.getView(R.id.ivAlbumDetialItemSel).setVisibility(View.VISIBLE);
            } else {
                Glide.with(getContext()).load(bean.getPath())
                        .into((ImageView) baseViewHolder.getView(R.id.ivAlbumDetailItemImg));
                baseViewHolder.getView(R.id.ivAlbumDetailItemSelImg).setVisibility(View.GONE);
                baseViewHolder.getView(R.id.ivAlbumDetailItemImg).setVisibility(View.VISIBLE);
                baseViewHolder.getView(R.id.ivAlbumDetialItemSel).setVisibility(View.GONE);
            }
        }
    }
}
